﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace XEvents.Library
{
    public class Predicate : XEObjectBase
    {
        internal Predicate(dm_xe_object obj, SqlServer server)
            : base(obj, server)
        { }

        private Predicate()
            : base(null)
        { }

        /// <summary>
        /// Type of Predicate
        /// </summary>
        public PredicateType PredicateType
        {
            get
            {
                switch (this.object_type)
                {
                    case "pred_source":
                        return PredicateType.Source;
                    default:
                        return PredicateType.Comparator;
                }
            }
        }

        /// <summary>
        /// Type
        /// </summary>
        public Type Type
        {
            get
            {
                return (from t in Server.MetaData.Types
                        where t.name == this.type_name && t.package_guid == this.type_package_guid
                        select t).ElementAtOrDefault(0);
            }
        }
    }
}